<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <!-- 主表单区域 -->
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="12" >
            <a-form-model-item label="商家名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchName">
              <a-input v-model="model.merchName" placeholder="请输入商家名称" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="行业分类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchCategory">
               <a-select v-model="model.merchCategory"  placeholder="请选择行业分类">
                <a-select-opt-group v-for="(obj,index) in parentData" :key="index" >
                    <template #label>
                    <span>
                      {{obj.text}}
                    </span>
                  </template>
                    <a-select-option  v-for="(sub,cindex) in parentData[index].children" :key="cindex" :value="sub.value" > {{sub.text}}</a-select-option>
                </a-select-opt-group>
               </a-select>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" >
            <a-form-model-item label="商家品牌" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchBrand">
              <a-input v-model="model.merchBrand" placeholder="请输入商家品牌" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="商家标签" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchTags">
              <div>
                <template v-for="(tag, index) in tags">
                  <a-tooltip v-if="tag.length > 20" :key="tag" :title="tag">
                    <a-tag :key="tag" :closable="index !== 0" @close="() => handleClose(tag)">
                      {{ `${tag.slice(0, 20)}...` }}
                    </a-tag>
                  </a-tooltip>
                  <a-tag v-else :key="tag" :closable="index !== -1" @close="() => handleClose(tag)">
                    {{ tag }}
                  </a-tag>
                </template>
                <a-input
                  v-if="inputVisible"
                  ref="input"
                  type="text"
                  size="small"
                  :style="{ width: '78px' }"
                  :value="inputValue"
                  @change="handleInputChange"
                  @blur="handleInputConfirm"
                  @keyup.enter="handleInputConfirm"
                />
                <a-tag v-else style="background: #fff; borderStyle: dashed;" @click="showInput">
                  <a-icon type="plus" /> 增加标签
                </a-tag>
              </div>
            </a-form-model-item>
          </a-col>
        </a-row> 
       
        <a-row>
          <a-col :span="12" >
            <a-form-model-item label="商家地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchAddress">
              <a-input v-model="model.merchAddress" placeholder="请输入商家地址" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="地址指引信息" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchAddressDetail">
              <a-input v-model="model.merchAddressDetail" placeholder="请输入地址指引信息" ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row> 
        <a-row>
          <a-col :span="12" >
            
            <a-form-model-item label="周一营业时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="time1">
              <a-checkbox  :checked="model.time1Flag=='1'?true:false"  @change="onTime1FlagChange">是否营业：</a-checkbox>
              <a-time-picker v-if="model.time1Flag=='1'"  v-model="model.merchStartTime1" :default-value="moment('07:00', 'HH:mm')" format="HH:mm" valueFormat="HH:mm" />
               <span v-if="model.time1Flag=='1'"> 至 </span>
               <span v-if="model.time1Flag=='0'"> 暂不营业 </span>
              <a-time-picker v-if="model.time1Flag=='1'" v-model="model.merchEndTime1" :default-value="moment('22:00', 'HH:mm')" format="HH:mm"  valueFormat="HH:mm"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            
            <a-form-model-item label="周二营业时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="time2">
                <a-checkbox  :checked="model.time2Flag=='1'?true:false"  @change="onTime2FlagChange">是否营业：</a-checkbox>
              <a-time-picker v-if="model.time2Flag=='1'" v-model="model.merchStartTime2" :default-value="moment('07:00', 'HH:mm')" format="HH:mm" valueFormat="HH:mm" /> 
               <span v-if="model.time2Flag=='1'"> 至 </span>
               <span v-if="model.time2Flag=='0'"> 暂不营业 </span>
              <a-time-picker v-if="model.time2Flag=='1'" v-model="model.merchEndTime2" :default-value="moment('22:00', 'HH:mm')" format="HH:mm"  valueFormat="HH:mm"  />
            </a-form-model-item>
          </a-col>
        </a-row> 
        <a-row>
          <a-col :span="12" >
            
            <a-form-model-item label="周三营业时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="time3">
               <a-checkbox  :checked="model.time3Flag=='1'?true:false"  @change="onTime3FlagChange">是否营业：</a-checkbox>
              <a-time-picker  v-if="model.time3Flag=='1'" v-model="model.merchStartTime3" :default-value="moment('07:00', 'HH:mm')" format="HH:mm" valueFormat="HH:mm" /> 
               <span v-if="model.time3Flag=='1'"> 至 </span>
               <span v-if="model.time3Flag=='0'"> 暂不营业 </span>
              <a-time-picker  v-if="model.time3Flag=='1'" v-model="model.merchEndTime3" :default-value="moment('22:00', 'HH:mm')" format="HH:mm"  valueFormat="HH:mm"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="周四营业时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="time4">
             <a-checkbox  :checked="model.time4Flag=='1'?true:false"  @change="onTime4FlagChange">是否营业：</a-checkbox>
              <a-time-picker  v-if="model.time4Flag=='1'" v-model="model.merchStartTime4" :default-value="moment('07:00', 'HH:mm')" format="HH:mm" valueFormat="HH:mm" /> 
              <span v-if="model.time4Flag=='1'"> 至 </span>
              <span v-if="model.time4Flag=='0'"> 暂不营业 </span>
              <a-time-picker  v-if="model.time4Flag=='1'" v-model="model.merchEndTime4" :default-value="moment('22:00', 'HH:mm')" format="HH:mm"  valueFormat="HH:mm"  />
            </a-form-model-item>
          </a-col>
        </a-row> 
          <a-row>
          <a-col :span="12" >
            <a-form-model-item label="周五营业时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="time5">
              <a-checkbox  :checked="model.time5Flag=='1'?true:false"  @change="onTime5FlagChange">是否营业：</a-checkbox>
              <a-time-picker  v-if="model.time5Flag=='1'"  v-model="model.merchStartTime5" :default-value="moment('07:00', 'HH:mm')" format="HH:mm" valueFormat="HH:mm" /> 
                 <span v-if="model.time5Flag=='1'"> 至 </span>
                <span v-if="model.time5Flag=='0'"> 暂不营业 </span>
              <a-time-picker  v-if="model.time5Flag=='1'"  v-model="model.merchEndTime5" :default-value="moment('22:00', 'HH:mm')" format="HH:mm"  valueFormat="HH:mm"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="周六营业时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="time6">
               <a-checkbox  :checked="model.time6Flag=='1'?true:false"  @change="onTime6FlagChange">是否营业：</a-checkbox>
              <a-time-picker  v-if="model.time6Flag=='1'"   v-model="model.merchStartTime6" :default-value="moment('07:00', 'HH:mm')" format="HH:mm" valueFormat="HH:mm" /> 
                <span v-if="model.time6Flag=='1'"> 至 </span>
                <span v-if="model.time6Flag=='0'"> 暂不营业 </span>
              <a-time-picker  v-if="model.time6Flag=='1'"  v-model="model.merchEndTime6" :default-value="moment('22:00', 'HH:mm')" format="HH:mm"  valueFormat="HH:mm"  />
            </a-form-model-item>
          </a-col>
        </a-row> 
         <a-row>
          <a-col :span="12" >
            <a-form-model-item label="周日营业时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="time7">
              <a-checkbox  :checked="model.time7Flag=='1'?true:false"  @change="onTime7FlagChange">是否营业：</a-checkbox>
              <a-time-picker  v-if="model.time7Flag=='1'" v-model="model.merchStartTime7" :default-value="moment('07:00', 'HH:mm')" format="HH:mm" valueFormat="HH:mm" /> 
                <span v-if="model.time7Flag=='1'"> 至 </span>
                <span v-if="model.time7Flag=='0'"> 暂不营业 </span>
              <a-time-picker  v-if="model.time7Flag=='1'" v-model="model.merchEndTime7" :default-value="moment('22:00', 'HH:mm')" format="HH:mm"  valueFormat="HH:mm"  />
            </a-form-model-item>
          </a-col>
        </a-row> 
        <a-row>
           <a-col :span="12" >
            <a-form-model-item label="联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchConcat">
              <a-input v-model="model.merchConcat" placeholder="请输入联系人" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchPhone">
              <a-input v-model="model.merchPhone" placeholder="请输入联系电话" ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row> 
        <a-row>
          <a-col :span="12" >
            <a-form-model-item label="是否首推" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchIndexFlag">
               <a-switch checked-children="是" un-checked-children="否"  :checked="model.merchIndexFlag=='1'?true:false" @change="onIndexChange"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="首推优先级" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchSort">
              <a-input-number  v-model="model.merchSort" placeholder="数字越大，优先级越高" :default-value="1" style="width:100%"></a-input-number>
            </a-form-model-item>
          </a-col>
        </a-row> 
        <a-row>
          <a-col :span="12" >
            <a-form-model-item label="商户状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchStatus">
              <a-switch checked-children="启用" un-checked-children="停用" :checked="model.merchStatus=='1'?true:false" @change="onStatusChange"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="所属城市" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchCity">
              <!-- <a-input v-model="model.merchCity" placeholder="请选择所属城市" ></a-input> -->
              <j-dict-select-tag v-model="model.merchCity" placeholder="请选择所属城市" dict-code="merch_citys"/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row v-if="false">
          <a-col :span="12" >
            <a-form-model-item label="经纬度信息" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="longitudeAndlatitude" >
                <a-input v-model="model.longitudeAndlatitude"  placeholder="请输入经纬度信息" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="经纬度设置帮助指引" :labelCol="labelCol" :wrapperCol="wrapperCol" >
                   <a-button @click="openBaidu" type="primary">点击打开百度地图查询经纬度页面，输入地址查询<a-icon type="right" /> </a-button>
            </a-form-model-item>
          </a-col>
        </a-row>
         <a-row>
          <a-col :span="24">
            <a-form-model-item label="商家简介" :labelCol="{ xs: { span: 24 }, sm: { span: 3 }}" :wrapperCol="{xs: { span: 20 },sm: { span: 20 }}" prop="merchDesc">
              <a-textarea v-model="model.merchDesc" :rows="3"  allow-clear placeholder="请输入商家简介" ></a-textarea>
            </a-form-model-item>
          </a-col>
        </a-row>
         <a-row>
          <a-col :span="12">
            <a-form-model-item label="LOGO建议(130:130)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchLogo">
                <j-image-upload class="avatar-uploader" text="上传" v-model="model.merchLogo" ></j-image-upload>
            </a-form-model-item>
          </a-col>
           <a-col :span="12">
            <a-form-model-item label="商家图片(750:586)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchIndexImg">
                <j-image-upload class="avatar-uploader" text="上传" v-model="model.merchIndexImg" :isMultiple="true" ></j-image-upload>
            </a-form-model-item>
          </a-col>
        </a-row> 
      </a-form-model>
    </j-form-container>
      <!-- 子表单区域 -->
    <a-tabs v-model="activeKey" @change="handleChangeTabs">
      <a-tab-pane tab="商家管理员信息" :key="refKeys[0]" :forceRender="true">
        <j-editable-table
          :ref="refKeys[0]"
          :loading="adhMerchUserTable.loading"
          :columns="adhMerchUserTable.columns"
          :dataSource="adhMerchUserTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :actionButton="true"/>
      </a-tab-pane>
    </a-tabs>
  </a-spin>
</template>

<script>

  import { postAction,getAction } from '@/api/manage'
  import { FormTypes,getRefPromise,VALIDATE_NO_PASSED } from '@/utils/JEditableTableUtil'
  import { JEditableTableModelMixin } from '@/mixins/JEditableTableModelMixin'
  import { validateDuplicateValue } from '@/utils/util'
  import moment from 'moment'
  export default {
    name: 'AdhMerchInfoForm',
    mixins: [JEditableTableModelMixin],
    
    components: {
    },
   
    data() {
      const time1Validator = (rule, value, callback) => {
          if(this.model.time1Flag=="1"){
            if (!(this.model.merchStartTime1&&this.model.merchStartTime1.length>0) || !(this.model.merchEndTime1&&this.model.merchEndTime1.length>0) ) {
              callback(new Error('请输入周一营业时间范围！'));
            } else {
              callback();
            }
          }else{
              callback();
          }
        };
        const time2Validator = (rule, value, callback) => {
           if(this.model.time2Flag=="1"){
              if (!(this.model.merchStartTime2&&this.model.merchStartTime2.length>0) || !(this.model.merchEndTime2&&this.model.merchEndTime2.length>0) ) {
                callback(new Error('请输入周二营业时间范围！'));
              } else {
                callback();
              }
           }else{
              callback();
           }
        };
        const time3Validator = (rule, value, callback) => {
           if(this.model.time3Flag=="1"){
             if (!(this.model.merchStartTime3&&this.model.merchStartTime3.length>0) || !(this.model.merchEndTime3&&this.model.merchEndTime3.length>0) ) {
                callback(new Error('请输入周三营业时间范围！'));
              } else {
                callback();
              }
           }else{
            callback();
           }
        };
        const time4Validator = (rule, value, callback) => {
          if(this.model.time4Flag=="1"){
            if (!(this.model.merchStartTime4&&this.model.merchStartTime4.length>0) || !(this.model.merchEndTime4&&this.model.merchEndTime4.length>0) ) {
              callback(new Error('请输入周四营业时间范围！'));
            } else {
              callback();
            }
          }else{
            callback();
          }
        };
        const time5Validator = (rule, value, callback) => {
          if(this.model.time5Flag=="1"){
             if (!(this.model.merchStartTime5&&this.model.merchStartTime5.length>0) || !(this.model.merchEndTime5&&this.model.merchEndTime5.length>0) ) {
              callback(new Error('请输入周五营业时间范围！'));
            } else {
              callback();
            }
          }else{
            callback();
          }
        };
        const time6Validator = (rule, value, callback) => {
          if(this.model.time6Flag=="1"){
            if (!(this.model.merchStartTime6&&this.model.merchStartTime6.length>0) || !(this.model.merchEndTime6&&this.model.merchEndTime6.length>0) ) {
              callback(new Error('请输入周六营业时间范围！'));
            } else {
              callback();
            }
          }else{
            callback();
          }
        };
        const time7Validator = (rule, value, callback) => {
          if(this.model.time7Flag=="1"){
            if (!(this.model.merchStartTime7&&this.model.merchStartTime7.length>0) || !(this.model.merchEndTime7&&this.model.merchEndTime7.length>0) ) {
              callback(new Error('请输入周日营业时间范围！'));
            } else {
              callback();
            }
          }else{
            callback();
          }
        };
        const longitudeAndlatitudeValidator = (rule, value, callback) => {
          if (!(this.model.longitudeAndlatitude&&this.model.longitudeAndlatitude.length>0)) {
            callback(new Error('请输入经纬度信息！'));
          } else {
            if(this.model.longitudeAndlatitude.split(",").length!=2){
               callback(new Error('输入经纬度信息有误,经度和纬度信息用户逗号隔开！'));
            }else{
              var reg1 =  /^[\-\+]?(0?\d{1,2}\.\d{1,6}|1[0-7]?\d{1}\.\d{1,6}|180\.0{1,6})$/;
              var reg2 =  /^[\-\+]?([0-8]?\d{1}\.\d{1,6}|90\.0{1,6})$/;
              var longitude = this.model.longitudeAndlatitude.split(",")[0];
              var latitude = this.model.longitudeAndlatitude.split(",")[1];
              if(!reg1.test(longitude)){
                 callback(new Error('输入经度信息格式不正确！'));
              }else if(!reg2.test(latitude)){
                 callback(new Error('输入纬度信息格式不正确！'));
              }else{
                 callback();
              }
            }
          }
        };
      return {
        tags: [],
        inputVisible: false,
        inputValue: '',

        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        labelCol2: {
          xs: { span: 24 },
          sm: { span: 3 },
        },
        wrapperCol2: {
          xs: { span: 24 },
          sm: { span: 20 },
        },
        model:{
        },
        // 新增时子表默认添加几行空数据
        addDefaultRowNum: 1,
        

        validatorRules: {
          merchName:[{required: true, message: '请输入商家名称!',maxlength:3,}],
          merchCategory:[{required: true, message: '请选择行业分类!',}],
          merchCity:[{required: true, message: '请选择所属城市!',}],
          merchAddress:[{required: true, message: '请输入商家地址!',}],
          time1:[{validator: time1Validator}],
          time2:[{validator: time2Validator}],
          time3:[{validator: time3Validator}],
          time4:[{validator: time4Validator}],
          time5:[{validator: time5Validator}],
          time6:[{validator: time6Validator}],
          time7:[{validator: time7Validator}],
          merchConcat:[{required: true, message: '请输入联系人!',}],
          merchPhone:[{required: true, message: '请输入联系电话!',}],
          longitudeAndlatitude:[{validator: longitudeAndlatitudeValidator}]
        },
        refKeys: ['adhMerchUser', ],
        tableKeys:['adhMerchUser', ],
        activeKey: 'adhMerchUser',
        // 商家管理员信息
        adhMerchUserTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '管理员姓名',
              key: 'userName',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '管理员手机号',
              key: 'userPhone',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
          ]
        },
         parentData:[],
        url: {
          parentData:"/adh/shopCategory/queryParentData",
          add: "/merch/adhMerchInfo/add",
          edit: "/merch/adhMerchInfo/edit",
          queryById: "/merch/adhMerchInfo/queryById",
          adhMerchUser: {
            list: '/merch/adhMerchInfo/queryAdhMerchUserByMainId'
          },
        }
      }
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
      this.queryParentData();

    },
    methods: {
      filterOption(input, option) {
        console.log(option)
        return (
          option.componentOptions.children[0].componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
        );
      },
      openBaidu:function(){
          window.open("https://api.map.baidu.com/lbsapi/getpoint/index.html", '_blank');
      },
      queryParentData(){
        var that = this;
        getAction(this.url.parentData,{}).then((res)=>{
        if(res.success){
            that.parentData = res.result;
          }
        })
      },
       moment,
      onStatusChange(checked){
        if(checked){
          this.model.merchStatus ="1";
        }else{
          this.model.merchStatus ="0";
        }
      },

      onTime1FlagChange(e){
        if(e.target.checked){
          this.model.time1Flag = "1";
        }else{
          this.model.time1Flag = "0";
        }
      },
     onTime2FlagChange(e){
        if(e.target.checked){
          this.model.time2Flag ="1";
        }else{
          this.model.time2Flag ="0";
        }
      },
       onTime3FlagChange(e){
        if(e.target.checked){
          this.model.time3Flag ="1";
        }else{
          this.model.time3Flag ="0";
        }
      },
       onTime4FlagChange(e){
        if(e.target.checked){
          this.model.time4Flag ="1";
        }else{
          this.model.time4Flag ="0";
        }
      },
     onTime5FlagChange(e){
        if(e.target.checked){
          this.model.time5Flag ="1";
        }else{
          this.model.time5Flag ="0";
        }
      },
        onTime6FlagChange(e){
        if(e.target.checked){
          this.model.time6Flag ="1";
        }else{
          this.model.time6Flag ="0";
        }
      },
      onTime7FlagChange(e){
        if(e.target.checked){
          this.model.time7Flag ="1";
        }else{
          this.model.time7Flag ="0";
        }
      },
      onIndexChange(checked){
         if(checked){
          this.model.merchIndexFlag ="1";
        }else{
          this.model.merchIndexFlag ="0";
        }
      },
      handleClose(removedTag) {
        const tags = this.tags.filter(tag => tag !== removedTag);
        this.tags = tags;
      },
      showInput() {
        this.inputVisible = true;
        this.$nextTick(function() {
          this.$refs.input.focus();
        });
      },
      handleInputChange(e) {
        this.inputValue = e.target.value;
      },
     
      handleInputConfirm() {
        const inputValue = this.inputValue;
        let tags = this.tags;
        if (inputValue && tags.indexOf(inputValue) === -1) {
          tags = [...tags, inputValue];
        }
        Object.assign(this, {
          tags,
          inputVisible: false,
          inputValue: '',
        });
        this.model.merchTags = tags.join(",");
      },
      addBefore(){
        this.adhMerchUserTable.dataSource=[]
        this.model.merchStartTime1 = "07:00";
        this.model.merchStartTime2 = "07:00";
        this.model.merchStartTime3 = "07:00";
        this.model.merchStartTime4 = "07:00";
        this.model.merchStartTime5 = "07:00";
        this.model.merchStartTime6 = "07:00";
        this.model.merchStartTime7 = "07:00";
        this.model.merchEndTime1 = "23:00";
        this.model.merchEndTime2 = "23:00";
        this.model.merchEndTime3 = "23:00";
        this.model.merchEndTime4 = "23:00";
        this.model.merchEndTime5 = "23:00";
        this.model.merchEndTime6 = "23:00";
        this.model.merchEndTime7 = "23:00";
      },
      getAllTable() {
        let values = this.tableKeys.map(key => getRefPromise(this, key))
        return Promise.all(values)
      },
      /** 调用完edit()方法之后会自动调用此方法 */
      editAfter() {
        this.$nextTick(() => {
        })
        // 加载子表数据
        if (this.model.id) {
          let params = { id: this.model.id }
          this.requestSubTableData(this.url.adhMerchUser.list, params, this.adhMerchUserTable)
        }
        if(this.model.merchTags&&this.model.merchTags.length>0){
         this.tags =  this.model.merchTags.split(',');
        }
        if(this.model.longitude && this.model.latitude){
          this.model.longitudeAndlatitude = this.model.longitude+","+this.model.latitude
        }
     //   this.model.longitudeAndlatitude = this.model.longitude+","+this.model.latitude
      },
      //校验所有一对一子表表单
      validateSubForm(allValues){

          return new Promise((resolve,reject)=>{
            Promise.all([
            ]).then(() => {
              resolve(allValues)
            }).catch(e => {
              if (e.error === VALIDATE_NO_PASSED) {
                // 如果有未通过表单验证的子表，就自动跳转到它所在的tab
                this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index]
              } else {
                console.error(e)
              }
            })
          })
      },
      /** 整理成formData */
      classifyIntoFormData(allValues) {
    
        let main = Object.assign(this.model, allValues.formValue)
        return {
          ...main, // 展开
          adhMerchUserList: allValues.tablesValue[0].values,
        }
      },
      validateError(msg){
        this.$message.error(msg)
      },

    }
  }
</script>

<style scoped>
</style>
<style>
.avatar-uploader > .ant-upload {
  width: 128px;
  height: 128px;
}
.ant-upload-select-picture-card i {
  font-size: 32px;
  color: #999;
}

.ant-upload-select-picture-card .ant-upload-text {
  margin-top: 8px;
  color: #666;
}
</style>